#include "Wakeup.h"
#include "Codec.h"

static int m_confidence;

void CodecInit(void)
{
	m_confidence = 1000;
}

void CodecRelease(void)
{
}

int Encode(short* in, int* out)
{
	int i;
	int mm = 1;

	for(i=0; i<HDRCNT*BUFLEN; i++)
	{
		if(mm < WAKEUP_ABS(in[i]))
			mm = WAKEUP_ABS(in[i]);
	}

	mm += 1;

	if(mm < 1000)
		return 0;

	for(i=0; i<HDRCNT*BUFLEN; i++)
	{
		out[i] = in[i] * SCALE / mm;
	}

	return 1;
}

int Decode(int* out)
{
	//return (out[0] > m_confidence) ? 1 : 0;
	return out[0];
}
